package com.haizhi.crm.sys.auth.dao;

import com.haizhi.crm.sys.auth.model.ResourcePermissionDo;
import com.haizhi.crm.sys.auth.model.ResourcePermissionVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by yangyijun on 2018/5/10.
 */
@Repository
public interface ResourcePermissionDao extends JpaRepository<ResourcePermissionDo, Long> {

    @Query(value = "select new com.haizhi.crm.sys.auth.model.ResourcePermissionVo" +
            "(r.id,r.parentId,p.id,p.name) " +
            "from ResourceDo r,ResourcePermissionDo rp,PermissionDo p " +
            "where r.id=rp.resourceId and rp.permissionId=p.id" )
    List<ResourcePermissionVo> list();
}
